package com.ity.teamanagement.controller;

import com.ity.teamanagement.annocation.CheckAuthorityStatus;
import com.ity.teamanagement.code.SysConfigCode;
import com.ity.teamanagement.entity.inputParam.*;
import com.ity.teamanagement.result.Result;
import com.ity.teamanagement.service.SystemConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author coderFu
 * @create 2021/6/5
 */
@RestController
@Api(tags = "后台系统配置模块")
@RequestMapping("/config")
public class SystemConfigController {

    @Autowired
    private SystemConfigService systemConfigService;

    @GetMapping("/findQrCodeUrl")
    @ApiOperation("默认配置二维码路径的URL")
    @CheckAuthorityStatus
    public Result findQrCodeUrl(){
        systemConfigService.findQrCodeUrl();
        return Result.success(SysConfigCode.URL_SET_SUCCESS);
    }

    @GetMapping("/findAllUrlConifg")
    @ApiOperation("查询所有二维码系统配置")
    @CheckAuthorityStatus
    public Result findAllUrlConfig(){
        return Result.success(systemConfigService.findAllUrlConfig());
    }

    @PutMapping("/updateUrlConfigById")
    @ApiOperation("根据id修改二维码路径配置")
    @CheckAuthorityStatus
    public Result updateUrlConfigById(@RequestBody SysUrlParam sysUrlParam){
        systemConfigService.updateUrlConfigById(sysUrlParam);
        return Result.success(SysConfigCode.URL_UPDATE_SUCCESS);
    }

    @DeleteMapping("/deleteUrlConfigByIds")
    @ApiOperation("根据id删除二维码配置信息")
    @CheckAuthorityStatus
    public Result deleteUrlConfigByIds(@RequestBody List<Long> ids){
        systemConfigService.deleteUrlConfigByIds(ids);
        return Result.success(SysConfigCode.URL_DELETE_SUCCESS);
    }

    @PostMapping("/addQrCodeUrl")
    @ApiOperation("添加二维码配置信息")
    @CheckAuthorityStatus
    public Result addQrCodeUrl(@RequestBody SysUrlParam sysUrlParam){
        systemConfigService.addQrCodeUrl(sysUrlParam);
        return Result.success(SysConfigCode.URL_ADD_SUCCESS);
    }

    @PostMapping("/settingQrCodeUrl")
    @ApiOperation("设置当前配置为使用配置")
    @CheckAuthorityStatus
    public Result settingQrCodeUrl(@RequestParam("id") Long id){
        systemConfigService.settingQrCodeUrl(id);
        return Result.success(SysConfigCode.URL_SET_SUCCESS);
    }

    @GetMapping("/checkOpenStatus")
    @ApiOperation("检查前台是否开放")
    public Result checkOpenStatus(){
        return Result.success(systemConfigService.checkOpenStatus());
    }

    @PostMapping("/closeReceptionShow")
    @ApiOperation("关闭前台显示")
    @CheckAuthorityStatus
    public Result closeReceptionShow(){
        systemConfigService.closeReceptionShow();
        return Result.success();
    }

    @PostMapping("/openReceptionShow")
    @ApiOperation("开启前台显示")
    @CheckAuthorityStatus
    public Result openReceptionShow(){
        systemConfigService.openReceptionShow();
        return Result.success();
    }

    @ApiOperation("添加首页模块类别")
    @CheckAuthorityStatus
    @PostMapping("/addHomeModule")
    public Result addHomeModule(@RequestBody@Validated AddHomeModuleParam addHomeModuleParam){
        return systemConfigService.addHomeModule(addHomeModuleParam);
    }

    @ApiOperation("删除首页模块类别")
    @CheckAuthorityStatus
    @DeleteMapping("/deleteHomeModule")
    public Result deleteHomeModule(@RequestBody@Validated DeleteHomeModuleParam deleteHomeModuleParam){
        return systemConfigService.deleteHomeModule(deleteHomeModuleParam);
    }

    @ApiOperation("修改首页模块类别信息")
    @CheckAuthorityStatus
    @PutMapping("/updateHomeModule")
    public Result updateHomeModule(@RequestBody@Validated UpdateHomeModuleParam updateHomeModuleParam){
        return systemConfigService.updateHomeModule(updateHomeModuleParam);
    }

    @ApiOperation("获取所有首页模块信息")
    @GetMapping("/getHomeModule")
    public Result getHomeModule(){
        return systemConfigService.getHomeModule();
    }

    @ApiOperation("根据模块id获取模块导航信息")
    @GetMapping("/getHomeModuleById")
    public Result getHomeModuleById(@Validated SelectHomeModuleParam selectHomeModuleParam){
        return systemConfigService.getHomeModuleById(selectHomeModuleParam);
    }

    @ApiOperation("新增底部导航")
    @CheckAuthorityStatus
    @PostMapping("/addDownNavigation")
    public Result addDownNavigation(@RequestBody@Validated AddDownNavigationParam addDownNavigationParam){
        return systemConfigService.addDownNavigation(addDownNavigationParam);
    }

    @ApiOperation("删除低保导航")
    @CheckAuthorityStatus
    @DeleteMapping("/deleteDownNavigation")
    public Result deleteDownNavigation(@RequestBody@Validated DeleteDownNavigationParam deleteDownNavigationParam){
        return systemConfigService.deleteDownNavigation(deleteDownNavigationParam);
    }

    @ApiOperation("修改底部导航信息")
    @CheckAuthorityStatus
    @PutMapping("/updateDownNavigation")
    public Result updateDownNavigation(@RequestBody@Validated UpdateDownNavigationParam updateDownNavigationParam){
        return systemConfigService.updateDownNavigation(updateDownNavigationParam);
    }

    @ApiOperation("查询底部导航信息")
    @GetMapping("/getDownNavigation")
    public Result getDownNavigation(){
        return systemConfigService.getDownNavigation();
    }

    @ApiOperation("根据底部导航id查询底部导航信息")
    @GetMapping("/getDownNavigationById")
    public Result getDownNavigationById(@Validated SelectDownNavigationParam selectDownNavigationParam){
        return systemConfigService.getDownNavigationById(selectDownNavigationParam);
    }







}
